Skip to content

KNOX-2412 - Add Logout Link to Home Page for Select Authentication Pr…#372

Merged
lmccay merged 2 commits into
apache:masterfrom
lmccay:KNOX-2412
Sep 6, 2020
Merged

KNOX-2412 - Add Logout Link to Home Page for Select Authentication Pr…#372
lmccay merged 2 commits into
apache:masterfrom
lmccay:KNOX-2412

Conversation

@lmccay
Copy link
Copy Markdown
Contributor

@lmccay lmccay commented Sep 4, 2020

What changes were proposed in this pull request?

  • Logout Button on Homepage
  • Homepage Logout Configurable from gateway-site.xml
  • KNOXSSOUT service changed to be able to be hosted in arbitrary topologies - may break existing use of this service in a dedicated knoxssout.xml topology which was the original intent but it was never really documented as supported.
  • KNOX-SESSION API added to return authenticated user and optionally logoutUrl
  • A SessionInformation section added to the Homepage with a Welcome {username} and logout button
  • KNOXSSOUT and KNOX-SESSION added to homepage.xml topology by default
  • homePageLogoutEnabled defaults to true since the default KnoxSSO with form based IDP is supported.

Planned for Future

  • Move session-information module into the header
  • Integrate KNOXSSO with TokenStateServer feature for token revocation for cookie tokens
  • Extend KNOXSSOUT to revoke tokens on logout
  • Pluggable logout providers rather than a single logoutUrl mechanism so other IDP logout mechanisms can be integrated

How was this patch tested?

  • Existing unit tests run
  • SessionResourceTest unit test added

image

The following has homePageLogoutEnabled=false

image

…oviders

Change-Id: I963d526cc560d0e2e00745c9b42c7ad63ed29450
Copy link
Copy Markdown
Contributor

@smolnar82 smolnar82 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks really good; I only have some minor comments and questions to address.

Comment thread gateway-release/pom.xml
<dependency>
<groupId>org.apache.knox</groupId>
<artifactId>gateway-service-metadata</artifactId>
<artifactId>gateway-service-session</artifactId>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not add the new service as a separate dependency?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't know what you mean here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why the patch only shows up like this but the original gateway-service-metadata is still in there. I had originally copy and pasted it but forgot to change the name then went back and changed it. The merged file looks fine.

private static final String DEFAULT_SSO_COOKIE_NAME = "hadoop-jwt";

static final String RESOURCE_PATH = "/api/v1/webssout";
static final String RESOURCE_PATH = "knoxssout/api/v1/webssout";
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't get why do we need the knoxssout. This change makes the SSOUT API inconsistent with the rest of the APIs.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not all of the other APIs do that. It was done that way for APIs that were initially intended to be deployed to a single dedicated topology. Like the admin.xml.

import org.apache.knox.gateway.security.SubjectUtils;

@Singleton
@Path("session/api/v1/")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps changing this to api/v1/session to be consistent with another API endpoints?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't believe so - this is the session API, for now there is a sessioninfo but we could potentially add other things to it. It can be added to any topology and addressed via the session context path.

Comment on lines +41 to +42
console.debug('SessionInformationComponent --> getUser() --> dr.who');
return 'dr.who';
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not returning null?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dr.who is common in Hadoop world. While I don't like it - it is better than the UI saying "Welcome null". :)

// window.alert('Are you sure???');
console.debug('SessionInformationComponent --> attempting logout() --> ');
if (this.sessionInformation) {
if (this.getLogoutUrl() == null) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd use this.logoutSupported so that the logic if logout is supported happens in one place only (in setSessionInformation).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I'll make that change - thanks!

console.debug('SessionInformationComponent --> attempting logout() --> ');
if (this.sessionInformation) {
if (this.getLogoutUrl() == null) {
window.alert('Logout for the configured is IDP not supported.\nPlease close all browser windows to logout.');
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a more elegant way of notifying the end-users: using a module called sweetalert (https://www.npmjs.com/package/sweetalert). It's been used both on the Admin UI and on the Home Page. See this usage for instance:
https://github.com/apache/knox/blob/master/knox-homepage-ui/home/app/homepage.service.ts#L81

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't being used now since it doesn't render the button at all for now. I'm not sure which is better which is why I left it here for now. A missing logout button may seem like a bug but a logout button that doesn't log you out may be bad as well. At least it is known to be intentional and provides some insights though. Planned to follow up with discussion on this. If we go that route we can use sweetalert instead for sure.

Change-Id: If29679793a5ae4629b1f3788459baf5682fe8c35
@lmccay lmccay requested a review from smolnar82 September 4, 2020 22:50
@lmccay lmccay merged commit 235bfd4 into apache:master Sep 6, 2020
stoty pushed a commit to stoty/knox that referenced this pull request May 14, 2024
…tication Pr… (apache#372)

* KNOX-2412 - Add Logout Link to Home Page for Select Authentication Providers

Change-Id: If7a3acf3a9094b2aa528de9aa1edf3df86b9ef30
stoty pushed a commit to stoty/knox that referenced this pull request May 14, 2024
* changes:
  CDPD-14138 KNOX-2408 - Improved AliasBasedTokenState service and house-keeping (apache#371)
  CDPD-14898 KNOX-2412 - Add Logout Link to Home Page for Select Authentication Pr… (apache#372)
  CDPD-14138 KNOX-2402 - Adding Gateway performance testing (apache#365)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants